<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增数据源')" />
	<th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-datasource-add">
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">数据源编码：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="datasourceCode" name="datasourceCode" readonly="true" th:value="${datasourceCode}">
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">数据库IP：</label>
						<div class="col-sm-8">
							<input id="databaseIp" name="databaseIp" class="form-control" type="text" placeholder="127.0.0.1" required>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">数据库端口：</label>
						<div class="col-sm-8">
							<input id="databasePort" name="databasePort" class="form-control" type="text" placeholder="3306" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">数据库名称：</label>
						<div class="col-sm-8">
							<input id="databaseName" name="databaseName" class="form-control" type="text" required>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">数据库用户名：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" id="databaseUsername" name="databaseUsername" placeholder="root" required>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">数据库密码：</label>
						<div class="col-sm-8">
							<input id="databasePassword" name="databasePassword" class="form-control" type="password" required>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">驱动类：</label>
						<div class="col-sm-8">
							<select name="databaseDriverClassName" class="form-control m-b" th:with="type=${@dict.getType('sys_database_type')}" >
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label">数据库标识：</label>
						<div class="col-sm-8">
							<select name="databaseFlag" class="form-control m-b" th:with="type=${@dict.getType('sys_database_flag')}">
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">所属租户：</label>
						<div class="col-xs-10">
							<select id="tenantCode" name="tenantCode" class="form-control m-b">
								<option th:each="tenant:${tenants}" th:value="${tenant.tenantCode}" th:text="${tenant.tenantName}"></option>
							</select>
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label class="col-xs-2 control-label">备注：</label>
						<div class="col-xs-10">
							<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
						</div>
					</div>
				</div>
			</div>

		</form>
	</div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/datasource";
		
		$("#form-datasource-add").validate({
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				$.operate.save(prefix + "/add", $('#form-datasource-add').serialize());
	        }
	    }
	</script>
</body>
</html>
